﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraBars;
using WHC.Framework.Commons;

using UI;
using Common;
using UI.BasicData;
using Entity;
using DataBusiness;
using System.Collections;
using UI.CasingsDesign;

namespace UI
{
    public partial class frmMain : DevExpress.XtraEditors.XtraForm
    {
        string well_id = "";
        int areaID = 0;
        private DataTable selectedWellStruct;
        private Hashtable selectedCasing;
        public frmMain()
        {
            InitializeComponent();
            InitTree();
            barStaticItem6.Caption = DateTime.Now.ToLongDateString();
            ChildWinManagement.LoadMdiForm(this, typeof(sql.frmAPI));

        }
        private void InitTree()
        {
            treeView1.ExpandAll();
        }

        private void barLargeButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmArea frm = new frmArea();
            frm.ShowDialog();
        }

        private void barLargeButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmWell));
        }

        private void barLargeButtonItem6_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(sql.frmAPI));
        }

        private void barLargeButtonItem7_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(sql.frmNoAPI));
        }

        private void barLargeButtonItem8_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmSelfAPI));
        }

        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmArea f = new frmArea();
            f.ShowDialog();
        }

        private void barButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmWell f = new frmWell();
            f.ShowDialog();
        }

        private void barButtonItem11_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmArea));
        }

        private void barButtonItem15_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmWell));
        }

        private void barButtonItem12_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(sql.frmAPI));
        }

        private void barButtonItem13_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(sql.frmNoAPI));
        }

        private void barButtonItem14_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmSelfAPI));
        }

        private void 新建井ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            frmWell f = new frmWell();
            f.ShowDialog();
        }

        private void 新建井ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            frmArea f = new frmArea();
            f.ShowDialog();
        }

        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (treeView1.SelectedNode.Text.Contains("南堡P-151"))
                ChildWinManagement.LoadMdiForm(this, typeof(frmArea));
            else if (treeView1.SelectedNode.Text.Contains("南堡151"))
                ChildWinManagement.LoadMdiForm(this, typeof(frmWell));
            foreach (var f in MdiChildren)
            {
                f.Close();
            }
        }

        private void barLargeButtonItem17_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmLithologicSection));
        }

        /// <summary>
        /// 点击编辑井身结构设计
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barLargeButtonItem9_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        /// <summary>
        /// 点击树形结构Node触发的事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        //{
        //    string nodeName = e.Node.Name.ToString();
        //    //获得区块号
        //    if (nodeName.Equals("区块号"))
        //    {
        //        string[] areaIdArr = e.Node.Text.Split('-');
        //        areaID = int.Parse(areaIdArr[1]);
        //    }
        //    //获得井的No
        //    if (nodeName.Equals("井号"))
        //    {
        //        well_id = e.Node.Text;
        //    }
        //    switch (nodeName)
        //    {
        //        case "井号":
        //            areaID = int.Parse(e.Node.Parent.Text.Split('-')[1]);
        //            displayWellInfo(areaID, well_id);//导入该井的基本信息
        //            importDataForCasDesign(well_id);//导入该井的井身结构信息
        //            break;
        //        case "井身结构":
        //            well_id = e.Node.Parent.Text;
        //            load_wellStructSheet(well_id);
        //            break;
        //        case "套管柱结构":
        //            load_JWTGSheet();
        //            break;
        //        case "岩性剖面":
        //            load_lithologic_sectionSheet();
        //            break;
        //        case "钻具组合":
        //            load_DrillingComb("南堡P-151");
        //            break;
        //        case "井眼轨迹":
        //            well_id = e.Node.Parent.Text;
        //            load_wellTrackSheet(well_id);
        //            break;
        //        case "套管串":
        //            load_casingStringSheet();
        //            break;
        //        case "南堡151":
        //            load_well();
        //            break;
        //        case "压力剖面":
        //            load_XtraForm1();
        //            break;
        //        default:
        //            break;
        //    }
        //}

        /// <summary>
        /// 展示井的基本信息
        /// </summary>
        /// <param name="AreaID">区块号</param>
        /// <param name="WellNo">井号</param>
        private void displayWellInfo(int AreaID, string WellNo)
        {
            Form fwi = new frmWellInfo(AreaID, WellNo);
            fwi.MdiParent = this;
            fwi.Show();
        }

        /// <summary>
        /// 功能：从井身结构、压力剖面处导入信息
        /// 作者：李博
        /// 时间：2018-1-19
        /// </summary>
        /// <param name="WellNo"></param>
        private void importDataForCasDesign(string WellNo)
        {
            DataTable dt = WellStructBLL.GetWellStructByWellNo(WellNo);
            selectedWellStruct = dt;
            //清空套管列表信息
            CaslListCBEdit.Properties.Items.Clear();
            //导入套管列表数据
            string CasingInfoItem;
            foreach (DataRow dr in dt.Rows)
            {
                CasingInfoItem = dr["ID"] + " - " + dr["套管程序"].ToString();
                CaslListCBEdit.Properties.Items.Add(CasingInfoItem);
            }
        }

        private void load_XtraForm1()
        {
            Form xtraForm1 = new frmPressureProfile();
            xtraForm1.MdiParent = this;
            xtraForm1.Show();
        }
        private void load_DrillingComb(string id)
        {
            Form DrillingComb = new frmDrillingComb(id);
            DrillingComb.MdiParent = this;
            DrillingComb.Show();
        }
        private void load_well()
        {
            Form well = new frmWell();
            well.MdiParent = this;
            well.Show();
        }

        private void load_wellStructSheet(string wellId)
        {
            Form wellStruct = new frmWellStruct(wellId);
            wellStruct.MdiParent = this;
            wellStruct.Show();
        }
        private void load_lithologic_sectionSheet()
        {
            Form lithologic_section1 = new frmLithologicSection();
            lithologic_section1.MdiParent = this;
            lithologic_section1.Show();
        }

        private void load_wellTrackSheet(string WellNo)
        {
            Form wellTrack = new frmWellTrack(WellNo);
            wellTrack.MdiParent = this;
            wellTrack.Show();
        }

        private void load_JWTGSheet()
        {
            Form competitionWell = new frmCasingStru();
            competitionWell.MdiParent = this;
            competitionWell.Show();
        }

        private void load_casingStringSheet()
        {

        }

        //private void treeView1_MouseDown(object sender, MouseEventArgs e)
        //{
        //    if ((sender as TreeView) != null)
        //    {
        //        treeView1.SelectedNode = treeView1.GetNodeAt(e.X, e.Y);
        //    }
        //}

        private void barButtonItem17_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void barButtonItem18_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (MessageBox.Show("是否关闭窗口", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                System.Environment.Exit(System.Environment.ExitCode);
                this.Dispose();
                this.Close();
            }
        }

        private void barButtonItem22_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void barButtonItem29_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void barButtonItem23_ItemClick(object sender, ItemClickEventArgs e)
        {
            Form newBushingabrasion = new frmCasingMain();

            newBushingabrasion.Show();
        }

        private void barButtonItem40_ItemClick(object sender, ItemClickEventArgs e)
        {
            ChildWinManagement.LoadMdiForm(this, typeof(frmUserInfo));

        }

        private void barButtonItem41_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (MessageBox.Show("是否关闭窗口", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                System.Environment.Exit(System.Environment.ExitCode);
                this.Dispose();
                this.Close();
            }
        }

        private void btnSave_ItemClick(object sender, ItemClickEventArgs e)
        {
            //Entity.tb_UserModel tUser = new Entity.tb_UserModel();
            //tUser.UserName=
            //DataBusiness.UserBLL.InsertUser();
            //frmUserInfo fui = new frmUserInfo();
            //fui.GetAddData();
            //MessageBox.Show(treeView1.SelectedNode.Name);


            //DataBusiness.UserBLL.DeleteUser();
            //tb_UserModel tuser = new tb_UserModel();
            //DataTable dt = frmUserInfo.gridview_Source();
            //foreach (DataRow dr in dt.Rows)
            //{
            //    tuser.UserAccount = dr[0].ToString();
            //    tuser.UserName = dr[1].ToString();
            //    tuser.Password = dr[1].ToString();
            //    tuser.Tel = dr[2].ToString();
            //    tuser.UserType = dr[3].ToString();
            //    tuser.Company = dr[4].ToString();
            //    tuser.Position = dr[5].ToString();
            //    tuser.Duty = dr[6].ToString();
            //    tuser.State = (Enum_State)1;
            //    DataBusiness.UserBLL.InsertUser(tuser);
            //}

            string select_node = treeView1.SelectedNode.Text;
            //   string select_node = treeView1.SelectedNode.Name;
            switch (select_node)
            {
                case "岩性剖面":

                    break;
                case "压力剖面":

                    break;
                case "井身结构":

                    break;
                case "套管柱结构":

                    break;

                case "钻具组合":
                    frmDrillingComb.saveToDataBase();
                    break;
                case "井眼轨迹":

                    break;
                default:
                    break;
            }



        }

        private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (AppMethod.ConfirmYesNo("确定退出系统?"))
                Application.Exit();
        }

        private void btnTest_ItemClick(object sender, ItemClickEventArgs e)
        {
            frmDemo fDemo = new frmDemo();
            fDemo.MdiParent = this;
            fDemo.Show();
        }

        /// <summary>
        /// 点击输入设计系数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barSafetyFactor_ItemClick(object sender, ItemClickEventArgs e)
        {
            inputDesignParams();
        }

        /// <summary>
        /// 点击输入外挤载荷
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barExtrusionLoad_ItemClick(object sender, ItemClickEventArgs e)
        {
            inputExternalLoad();
        }

        /// <summary>
        /// 点击输入内压载荷
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barBurstLoad_ItemClick(object sender, ItemClickEventArgs e)
        {
            inputInternalLoad();
        }

        /// <summary>
        /// 点击输入轴向载荷
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barTensileLoad_ItemClick(object sender, ItemClickEventArgs e)
        {
            inputAxialLoad();
        }

        /// <summary>
        /// 点击输入水泥系数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem36_ItemClick(object sender, ItemClickEventArgs e)
        {
            inputCementCoe();
        }

        /// <summary>
        /// 点击套管组设计
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void barButtonItem11_ItemClick_1(object sender, ItemClickEventArgs e)
        {
            CasingDesign();
        }

        /// <summary>
        /// 点击获取选择的套管层
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CaslListCBEdit_SelectedIndexChanged(object sender, EventArgs e)
        {
            string casInfoStr = CaslListCBEdit.Properties.Items[CaslListCBEdit.SelectedIndex].ToString();
            string[] casInfoArr = casInfoStr.Split('-');
            for (int i = 0; i < casInfoArr.Length; i++)
            {
                casInfoArr[i] = casInfoArr[i].Trim();
            }
            //获取套管编号(ID)
            string ID = casInfoArr[0];
            string CasingProgram = casInfoArr[1];//套管程序(类型)
            float WellSize = 0;//套管尺寸(外径) mm
            float EndLocation = 0;//下入深度,单位 m
            float NextWellDepth = 0;//下次钻进目的井深,即下层套管的下入深度,单位 m
            float NextHighestDFD = 0;//下次钻进最高钻井液密度,单位 g/cm³

            foreach (DataRow dr in selectedWellStruct.Rows)
            {
                if (dr["ID"].Equals(ID))
                {
                    WellSize = float.Parse(dr["套管尺寸"].ToString());
                    EndLocation = float.Parse(dr["下入深度"].ToString());
                    NextWellDepth = float.Parse(dr["下次钻进目的井深"].ToString());
                    NextHighestDFD = float.Parse(dr["下次钻井所用最高钻井液密度"].ToString());
                }
            }
            //MessageBox.Show(ID + " " + CasingProgram + " " + WellSize + " " + EndLocation + " " + NextWellDepth + " " + NextHighestDFD);
            selectedCasing = new Hashtable();
            selectedCasing.Add("ID", ID);
            selectedCasing.Add("CasingProgram", CasingProgram);
            selectedCasing.Add("WellSize", WellSize);
            selectedCasing.Add("EndLocation", EndLocation);
            selectedCasing.Add("NextWellDepth", NextWellDepth);
            selectedCasing.Add("NextHighestDFD", NextHighestDFD);
        }

        /*
       * 描述：以下6个Method为套管柱设计步骤
       * 作者：李博
       * 日期：2018-1-19
       */
        /// <summary>
        /// 输入设计参数
        /// </summary>
        private void inputDesignParams()
        {
            frmCasingDesign fcd = new frmCasingDesign();
            fcd.StartPosition = FormStartPosition.CenterScreen;
            fcd.ShowDialog();
        }

        /// <summary>
        /// 输入水泥系数
        /// </summary>
        private void inputCementCoe()
        {

        }

        /// <summary>
        /// 输入内压载荷
        /// </summary>
        private void inputInternalLoad()
        {
            frmBurstLoad fbl = new frmBurstLoad();
            fbl.StartPosition = FormStartPosition.CenterScreen;
            fbl.ShowDialog();
        }

        /// <summary>
        /// 输入轴向载荷
        /// </summary>
        private void inputAxialLoad()
        {
            frmTensileLoad ftl = new frmTensileLoad();
            ftl.StartPosition = FormStartPosition.CenterScreen;
            ftl.ShowDialog();
        }

        /// <summary>
        /// 输入外挤载荷
        /// </summary>
        private void inputExternalLoad()
        {
            frmExtrusionLoad fel = new frmExtrusionLoad();
            fel.StartPosition = FormStartPosition.CenterScreen;
            fel.ShowDialog();
        }

        /// <summary>
        /// 套管柱设计
        /// </summary>
        private void CasingDesign()
        {
            //selectedWellStruct.Rows[]
            frmCasingBasicDesign fcd = new frmCasingBasicDesign(34.5f);
            fcd.MdiParent = this;
            fcd.Show();
        }


        /// <summary>
        /// 套管设计步骤选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>      
        private void CasDesignCBEdit_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selectedStep = CasDesignCBEdit.Properties.Items[CasDesignCBEdit.SelectedIndex].ToString();
            switch (selectedStep)
            {
                case "设计系数":
                    inputDesignParams();
                    break;
                case "水泥系数":
                    inputCementCoe();
                    break;
                case "外挤载荷":
                    inputExternalLoad();
                    break;
                case "内压载荷":
                    inputInternalLoad();
                    break;
                case "轴向载荷":
                    inputAxialLoad();
                    break;
                case "套管柱设计":
                    CasingDesign();
                    break;
                default:
                    break;
            }
        }
        /// <summary>
        /// 功能:动态加载树节点
        /// 作者:孟坤
        /// 时间:2018-1-19
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private DataTable dt = null;


        //获取根节点
        private void BindBoot()
        {
            DataRow[] ro = dt.Select("ParentId = '0'");//从dt表中查询出ParentId = 0 的行
            foreach (DataRow dr in ro)
            {
                TreeNode node = new TreeNode();
                node.Tag = dr;
                node.Text = dr["Name"].ToString();
                treeView1.Nodes.Add(node);

                AddChild(node);
            }
        }
        //绑定子节点
        private void AddChild(TreeNode node)
        {
            DataRow dr2 = (DataRow)node.Tag;//获取与根节点关联的数据行
            string pId = dr2["id"].ToString();//获取根节点的deptId

            //从dt表中查询出parentId=id的节点
            DataRow[] rows = dt.Select("ParentId='" + pId + "'");
            int a = rows.Length;

            if (rows.Length == 0)
                return;
            foreach (DataRow drow in rows) //再次遍历，添加子节点
            {
                TreeNode node3 = new TreeNode();
                node3.Tag = drow;
                node3.Text = drow["Name"].ToString();
                node.Nodes.Add(node3);

                //ContextMenuStrip.Name = "company";
                //递归
                AddChild(node3);
            }
            treeView1.ExpandAll();
        }
        /// <summary>
        /// 功能:为树添加右键
        /// 作者:孟坤
        /// 时间:2018-1-19
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {

            //string nodeName = e.Node.Name.ToString();
            string nodeName = e.Node.Text.ToString();
            //MessageBox.Show(nodeName);
            //获得区块号
            if (nodeName.Equals("南堡P-151"))
            {
                string[] areaIdArr = e.Node.Text.Split('-');
                areaID = int.Parse(areaIdArr[1]);
            }
            //获得井的No
            if (nodeName.Equals("井号"))
            {
                well_id = e.Node.Text;
            }
            switch (nodeName)
            {
                case "井号":
                    areaID = int.Parse(e.Node.Parent.Text.Split('-')[1]);
                    displayWellInfo(areaID, well_id);//导入该井的基本信息
                    importDataForCasDesign(well_id);//导入该井的井身结构信息
                    break;
                case "井身结构":
                    well_id = e.Node.Parent.Text;
                    load_wellStructSheet(well_id);
                    break;
                case "套管柱结构":
                    load_JWTGSheet();
                    break;
                case "岩性剖面":
                    load_lithologic_sectionSheet();
                    break;
                case "钻具组合":
                    load_DrillingComb("南堡P-151");
                    break;
                case "井眼轨迹":
                    well_id = e.Node.Parent.Text;
                    load_wellTrackSheet(well_id);
                    break;
                case "套管串":
                    load_casingStringSheet();
                    break;
                case "南堡151":
                    load_well();
                    break;
                case "压力剖面":
                    load_XtraForm1();
                    break;
                default:
                    break;
            }
            if (e.Button != MouseButtons.Right) return;
            if (e.Node.Level == 0)
            {
                TreeNode currentNode = this.treeView1.GetNodeAt(new Point(e.X, e.Y));
                ContextMenuStrip cms = new ContextMenuStrip();
                if (currentNode != null)
                {
                    ToolStripMenuItem editSelectInforCompany = new ToolStripMenuItem("查看公司信息");
                    ToolStripMenuItem editUpdateInforCompany = new ToolStripMenuItem("修改公司信息");
                    ToolStripMenuItem editCreateInforArea = new ToolStripMenuItem("新建区块信息");
                    //editAddproduct.Click += new EventHandler(editAddproduct_Click);
                    //editAddprChildoduct.Click += new EventHandler(editAddChildProduct_Click);
                    //editDeleteproduct.Click += new EventHandler(editDeleteproduct_Click);

                    cms.Items.Add(editSelectInforCompany);
                    cms.Items.Add(editUpdateInforCompany);
                    cms.Items.Add(editCreateInforArea);
                    cms.Show(this.treeView1, e.X, e.Y);
                    this.treeView1.SelectedNode = currentNode;

                }
            }
            if (e.Node.Level == 1)
            {
                TreeNode currentNode = this.treeView1.GetNodeAt(new Point(e.X, e.Y));
                ContextMenuStrip cms = new ContextMenuStrip();
                if (currentNode != null)
                {
                    ToolStripMenuItem editSelectInforArea = new ToolStripMenuItem("查看区块信息");
                    ToolStripMenuItem editUpdateInforArea = new ToolStripMenuItem("修改区块信息");
                    ToolStripMenuItem editCreateInforWell = new ToolStripMenuItem("新建井信息");
                    ToolStripMenuItem editUDeleteArea = new ToolStripMenuItem("删除区块");

                    //editCreateInforWell.Click += new EventHandler(editCreateInforWell_Click);
                    //editSelectInforArea.Click += new EventHandler(editSelectInforArea_Click);
                    //editAddprChildoduct.Click += new EventHandler(editAddChildProduct_Click);
                    //editDeleteproduct.Click += new EventHandler(editDeleteproduct_Click);
                    cms.Items.Add(editSelectInforArea);
                    cms.Items.Add(editUpdateInforArea);
                    cms.Items.Add(editCreateInforWell);
                    cms.Items.Add(editUDeleteArea);
                    cms.Show(this.treeView1, e.X, e.Y);
                    this.treeView1.SelectedNode = currentNode;

                }
            }
            if (e.Node.Level == 2)
            {
                TreeNode currentNode = this.treeView1.GetNodeAt(new Point(e.X, e.Y));
                ContextMenuStrip cms = new ContextMenuStrip();
                if (currentNode != null)
                {
                    ToolStripMenuItem editSelectInforWell = new ToolStripMenuItem("查看井信息");
                    ToolStripMenuItem editUpdateInforWell = new ToolStripMenuItem("修改井信息");
                    ToolStripMenuItem editDeleteInforWell = new ToolStripMenuItem("删除井");

                    editSelectInforWell.Click += new EventHandler(editSelectInforWell_Click);
                    //editUpdateInforWell.Click += new EventHandler(editUpdateInforWell_Click);
                    //editCreateInforWell.Click += new EventHandler(editCreateInforWell_Click);
                    cms.Items.Add(editSelectInforWell);
                    cms.Items.Add(editUpdateInforWell);
                    cms.Items.Add(editDeleteInforWell);
                    cms.Show(this.treeView1, e.X, e.Y);
                    this.treeView1.SelectedNode = currentNode;

                }
            }


        }
        /// <summary>
        /// 功能:右键点击事件：查看井信息
        /// 作者:孟坤
        /// 时间:2018-1-22
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void editSelectInforWell_Click(object sender, EventArgs e)
        {
            string[] areaIdArr = treeView1.SelectedNode.Text.Split('-');
            areaID = int.Parse(areaIdArr[1]);
            areaID = int.Parse(treeView1.SelectedNode.Parent.Text.Split('-')[1]);
            well_id = treeView1.SelectedNode.Text;
            displayWellInfo(areaID, well_id);//导入该井的基本信息
            importDataForCasDesign(well_id);//导入该井的井身结构信息
        }

       

        private void frmMain_Load(object sender, EventArgs e)
        {
            string sql = "select * from tb_WellRelation";
            dt = DataAccess.SqlHelper.QuerySqlByDataTable(sql);

            BindBoot();
        }

        //private void treeView1_Click(object sender, EventArgs e)
        //{
        //    if (treeView1.SelectedNode.Level == 1)
        //    {
        //        string Name = treeView1.SelectedNode.Text;
        //        tb_AreaModel model = new tb_AreaModel();
        //        DataSet ds = AreaBLL.GetArea(Name);
        //        if (ds.Tables[0].Rows.Count > 0)
        //        {
        //            model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
        //            model.ReservoirType = ds.Tables[0].Rows[0]["ReservoirType"].ToString();
        //            model.AcidType = ds.Tables[0].Rows[0]["AcidType"].ToString();
        //            model.ExplorationDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["ExplorationDate"]);
        //            model.ExploitDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["ExploitDate"]);
        //            model.ExploitStyle = ds.Tables[0].Rows[0]["ExploitStyle"].ToString();
        //            model.ExistingWells = Convert.ToInt32(ds.Tables[0].Rows[0]["ExistingWells"]);
        //            model.BlockLocation = ds.Tables[0].Rows[0]["BlockLocation"].ToString();
        //            model.Start_Location = Convert.ToDecimal(ds.Tables[0].Rows[0]["Start_Location"]);
        //            model.EndLocation = Convert.ToDecimal(ds.Tables[0].Rows[0]["EndLocation"].ToString());
        //            model.BlockArea = Convert.ToDecimal(ds.Tables[0].Rows[0]["BlockArea"]);
        //        }
        //        frmArea frm = new frmArea(model);
        //        frm.Text = "查看区块信息";
        //        frm.ShowDialog();
        //        treeView1.SelectedNode.Text = AppPara.Global_Area_Name;
        //        AppPara.Global_Area_Name = null;

        //    }
        //}
    }
}